<div class="row-fluid no-margin">
	<div class="span12">
		<ul class="quicktasks">
			<li>
				<a href="?action=manageuser"> <img
						src="<?php echo $view->layoutUrl;?>assets/img/icons/essen/32/back.png"
						alt=""> <span>BACK</span>
				</a>
			</li>
		</ul>
	</div>
</div>
<div class="row-fluid">
	<div class="span12">
		<div class="box">
			<div class="box-head">
				<h3>
                                    <?php if(isset($_GET['user_id'])){ ?>Edit permission of user <?php echo @$view->userdata['username'];?><?php } ?>
                                </h3>
			</div>
			<div class="box-content">
                            <?php if(count($_POST) > 0){?>
                            <div class="alert alert-info">
                                Data saved succsesfully
                            </div>
                            <?php } ?>
                            <?php if($view->error){?>
                            <div class="alert alert-error"><?php echo $view->error;?></div>
                            <?php } ?>
                                <form action="" class="validate form-horizontal" method="post">
                                    <?php if(isset($_GET['user_id'])){ ?>
                                    <input type="hidden" name="user_id" value="<?php echo $_GET['user_id'];?>" />
                                    <?php } ?>
					<fieldset>
                                                <?php foreach($view->permissionlist as $p) { ?>
                                                <div class="control-group">
                                                    <label for="<?php echo $p['key'];?>" class="control-label"></label>
                                                    <div class="controls">
                                                    <label style="margin-top: 5px;" class="checkbox">
                                                        <input type="checkbox" <?php if($p['is_allowed']){?> checked="checked" <?php } ?> class='uniform' name="permission[<?php echo $p['key'];?>]" id="<?php echo $p['key'];?>"> <?php echo $p['name'];?> </label>
                                                    </div>
                                                </div>
                                                <?php } ?>

						<div class="form-actions">
							<button class="btn btn-primary" type="submit">Save</button>
						</div>
					</fieldset>
				</form>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
    function generatePassword()
    {
        var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
        var string_length = 10;
        var randomstring = '';
        for (var i=0; i<string_length; i++) {
            var rnum = Math.floor(Math.random() * chars.length);
            randomstring += chars.substring(rnum,rnum+1);
        }
        $("#password").val(randomstring);
    }
    var s = document.getElementById("country");
    s.value = "<?php echo $view->userdata['extra_user_data']['country'];?>";
</script>